#include<stdio.h>
int main()
{
	int n,i,j,flat,a[30];
	int s=0;
	scanf("%d",&n);
	i=1;
	a[i]=2;
	while(1)
	{
		flat=1;
		if(a[i]!=i)
		{
			for(j=1;j<i;j++)
			{
				if(a[j]==a[i])
				{
				flat=0;
				break;	
				}
			}
		}
		else
		flat=0;
		if(flat&&i==n)
		{
			for(j=1;j<=n;j++)
			{
				printf("%d",a[j]);
			}
			if(++s %5 !=0)
			{
			printf(" ");
		    }
		else
		{
			printf("\n");
		}
	 } 
	 if(flat&&i<n)
	 {
	 	i++;
	 	a[i]=1;
	 	continue;
	 }
	 while(a[i]==n&&i>0)
	     i--;
	 if(i>0)
	     a[i]++;
	 else
	     break;
    }
    printf("\ns=%d",s);
    return 0;
}
